package com.erp.erp_ui.base;

import com.erp.utils.R;
import com.erp.utils.RSAEncrypt;
import com.erp.utils.ResultStatusEnum;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * @ClassName RSAControl
 * @Description 获取公钥
 * @Author songjizhen
 * @Date 2020/6/21 13:34
 * @Version 1.0
 */
@Controller
@RequestMapping(value = "codec")
 public class RSAControl {

    /**
     * 返回公钥
     * @return
     */
    @RequestMapping(value = "getPublicKeyString",method = RequestMethod.POST)
    @ResponseBody
     public R<String> getPublicKeyString()  {
        try {
            return R.build(RSAEncrypt.getPublicKeyString());
        }catch (Exception e){
            return R.buildError(ResultStatusEnum.CODEC_ERROR);
        }
    }
}
